##设置库名称
set(LIBRARY_TARGET_NAME modify_PE_console)
##查找所有头文件
file(GLOB_RECURSE  ${LIBRARY_TARGET_NAME}_HEADER_FILES
    LIST_DIRECTORIES False 
    "${PROJECT_SOURCE_DIR}/${LIBRARY_TARGET_NAME}/*.h"
)
##设置VS筛选器，头文件分文件夹
source_group(
    TREE "${PROJECT_SOURCE_DIR}/${LIBRARY_TARGET_NAME}"
    ##PREFIX "Header Files"
    FILES ${${LIBRARY_TARGET_NAME}_HEADER_FILES}
)

##查找所有源文件
file(GLOB_RECURSE  ${LIBRARY_TARGET_NAME}_SRC_FILES
    LIST_DIRECTORIES False 
    "${PROJECT_SOURCE_DIR}/${LIBRARY_TARGET_NAME}/*.cpp"
)
##设置VS筛选器，源码分文件夹
source_group(
    TREE "${PROJECT_SOURCE_DIR}/${LIBRARY_TARGET_NAME}"
    ##PREFIX "Source Files"
    FILES ${${LIBRARY_TARGET_NAME}_SRC_FILES}
)

##设置生成目标
add_executable(${LIBRARY_TARGET_NAME} 
    ${${LIBRARY_TARGET_NAME}_HEADER_FILES}
    ${${LIBRARY_TARGET_NAME}_SRC_FILES}
)
##添加别名

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")

set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES WIN32_EXECUTABLE ON)

set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES LINK_FLAGS "/SAFESEH:NO /LARGEADDRESSAWARE")


##指定工程生成文件组织结构
##set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES FOLDER ${FOLDER_NAME})


##设置预处理器定义
target_compile_definitions(${LIBRARY_TARGET_NAME} PRIVATE UNICODE NDEBUG WIN32)

##配置构建/使用时的头文件路径
target_include_directories(
    ${LIBRARY_TARGET_NAME}
    PUBLIC   
    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modify_PE_core/include>"
)

##配置库依赖
target_link_libraries(${LIBRARY_TARGET_NAME}
    PRIVATE ${PROJECT_NAME}::modify_PE_core
)

##安装构建结果
install(TARGETS ${LIBRARY_TARGET_NAME}
    EXPORT ${PROJECT_NAME}
    RUNTIME DESTINATION bin/${PROJECT_PLATFORM}/$<IF:$<CONFIG:DEBUG>,Debug,Release>
    ARCHIVE DESTINATION lib/${PROJECT_PLATFORM}/$<IF:$<CONFIG:DEBUG>,Debug,Release>
    LIBRARY DESTINATION lib/${PROJECT_PLATFORM}/$<IF:$<CONFIG:DEBUG>,Debug,Release>
)
##安装pdb(可选)
#install(FILES $<TARGET_PDB_FILE:${LIBRARY_TARGET_NAME}> DESTINATION bin/${PROJECT_PLATFORM}/$<IF:$<CONFIG:DEBUG>,Debug,Release> OPTIONAL)
